
include Bean 

module Oos4ruby
  class Media < Bean::BeanClass
    
    define_el_reader AtomNamespace => [:title, :updated, :content]
    
    attr_writer :title
    
    def initialize(entry, auth, slug = nil)
      @xml = entry
      @auth = auth
      @slug = slug || @xml.child('slug', OosNamespace).text      
    end
    
    def Media.dump!(opts, slug)
      if (opts[:file].instance_of?File)
        file = opts[:file]
      elsif (opts[:file].instance_of?String)
        file = File.new( opts[:file ])
      end      
      return file
    end
    
    private
    def load!
      if @title
        @xml.child('title').text = @title
      end
    end
    
  end
end
